\chapter{矩阵微积分}
\section{规则}
$y = f(\bm{x}) = f(x_1,x_2,\cdots,x_n)$可以叫做向量的标量值函数。它的偏导或者说得分向量可以写作，
\[
\frac{\partial f(\bm{x})}{\partial\bm{x}} = \begin{pmatrix}
	\partial y/\partial x_1\\
	\partial y/\partial x_2\\
	\vdots\\
	\partial y/\partial x_n
\end{pmatrix}
\]
\textbf{注意到导数的形状与分母的形状是一样的。}或者说导数的行是分母的行，导数的列是分子的列。然后该标量值函数的二阶导数或者说Hession矩阵可以写为,
\[
\begin{aligned}
	\bm{H}&=\begin{pmatrix}
		\partial^2 y/\partial x_1\partial x_1 & \partial^2 y/\partial x_1\partial x_2&\cdots& \partial^2 y/\partial x_1\partial x_n\\
		\partial^2 y/\partial x_2\partial x_1 & \partial^2 y/\partial x_2\partial x_2&\cdots& \partial^2 y/\partial x_2\partial x_n\\
		\vdots\\
		\partial^2 y/\partial x_n\partial x_1 & \partial^2 y/\partial x_n\partial x_2&\cdots& \partial^2 y/\partial x_n\partial x_n
	\end{pmatrix} \\
	&= \left[\frac{\partial(\partial y/\partial \bm{x})}{\partial x_1} \frac{\partial(\partial y/\partial \bm{x})}{\partial x_2}\cdots\frac{\partial(\partial y/\partial \bm{x})}{\partial x_n}\right]\\
	& = \frac{\partial(\partial y/\partial \bm{x})}{\partial \bm{x}'}
\end{aligned}
\]
\section{要记的}
线性函数可以写作$y = \bm{a'x}=\bm{x'a}$，因此，有，
\[
\frac{\partial\bm{a'x}}{\partial \bm{x}}=\bm{a}
\]
因为$\bm{x}$是列向量，所以求导后是$\bm{a}$而不是$\bm{a}'$。如果$\bm{y}$也是向量了，即$\bm{y} = \bm{Ax}$，那么，
\[
\frac{\partial\bm{Ax}}{\partial \bm{x}}=\bm{A}'
\]
对于二次函数$\bm{xA'x}$，则有，
\[
\frac{\partial\bm{x'Ax}}{\partial \bm{x}}=(\bm{A+A'})\bm{x}
\]
这些推导是很容易的，展开一个一个写就行。

